package com.atguigu.lease.common.handle;

import com.atguigu.lease.common.exception.MyBusinessException;
import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName MyExceptionHandle
 * @Author heartFade
 * @Date 2025-05-02 21:48
 * @Version 1.0
 * @Description TODO
 **/
@RestControllerAdvice
public class MyExceptionHandle {

    @ExceptionHandler(MyBusinessException.class)
    public Result handleMyBusinessException(MyBusinessException e)
    {
        return Result.fail(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(ExpiredJwtException.class)
    public Result handleExpiredJwtException(ExpiredJwtException e)
    {
        return Result.fail(ResultCodeEnum.TOKEN_EXPIRED.getCode(),ResultCodeEnum.TOKEN_EXPIRED.getMessage());
    }
}
